What is chrome-trace-event?
The chrome-trace-event npm package provides tools for creating and managing trace events in the format used by Chrome's tracing infrastructure. This is useful for developers who need to analyze performance issues or understand the behavior of their applications in a detailed and visual way.
What are chrome-trace-event's main functionalities?
Creating trace events
This feature allows developers to create instant trace events. The events are timestamped and can include additional arguments for more detailed analysis.
const tracer = require('chrome-trace-event').Tracer;
const trace = new tracer({ noStream: true });
trace.instantEvent({ name: 'myEvent', id: 1, args: { someDetail: 'detailValue' } });
trace.close();
Streaming trace events
This feature supports streaming trace events directly to a file or any writable stream, which is useful for capturing longer trace sessions without consuming too much memory.
const tracer = require('chrome-trace-event').Tracer;
const fs = require('fs');
const traceStream = fs.createWriteStream('trace.json');
const trace = new tracer({ stream: traceStream });
trace.instantEvent({ name: 'streamedEvent', id: 2 });
trace.close();
Other packages similar to chrome-trace-event
speedline
While not directly similar, speedline analyzes trace logs (like those generated by chrome-trace-event) to compute performance metrics and visual progress of web pages. It complements the output of chrome-trace-event by providing higher-level analysis tools.
chrome-trace-event: A node library for creating trace event logs of program
execution according to Google's Trace Event
format.
These logs can then be visualized with
trace-viewer or chrome devtools to grok one's programs.
Install
npm install chrome-trace-event
Usage
const Trace = require("chrome-trace-event").Tracer;
const trace = new Trace({
noStream: true
});
trace.pipe(fs.createWriteStream(outPath));
trace.flush();
Links
License
MIT. See LICENSE.txt.